<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 1、已知persons用户信息数据：

let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "33333" }
        ]

2、现有 let user = { username:"admin1",password:"12345" }

登录原理：
    如果persons中含有对应的用户名和密码则提示登录成功，否则提示用户名和密码错误
注册原理：
    如果persons中没有对应的用户，则把user追加到persons末尾 -->
    <script>
        let persons = [
            { "username": "xiaoming1", "password": "1111" },
            { "username": "xiaoming2", "password": "222" },
            { "username": "xiaoming3", "password": "33333" }
        ]
        let user = { username:"xiaoming1",password:"1111" };
     
        // let user =  { "username": "xiaoming3", "password": "333330" };
        
            persons.find(function(item,index,array){
            
                if(item.username == user.username && item.password == user.password){
                    document.write('登录成功')
                    return item.username == user.username && item.password == user.password
                }else{
                    persons = [...persons,user]
                    document.write('登录失败')
                }
               
                
               
            })
            
    
      
    </script>
</body>
</html>
